{% macro render_notification(notification) %}
    {% import _self as render %}
    {% if  notification.subject ==  'follow_user'%}
        {{ render.render_follow_user(notification) }}
    {% elseif notification.subject ==  'reply_topic' %}
        {{ render.render_reply_topic(notification) }}
    {% elseif notification.subject ==  'vote_topic' %}
        {{ render.render_vote_topic(notification) }}
    {% elseif notification.subject ==  'vote_reply' %}
        {{ render.render_vote_reply(notification) }}
    {% elseif notification.subject ==  'comment_post' %}
        {{ render.render_comment_post(notification) }}
    {% elseif notification.subject ==  'vote_post' %}
        {{ render.render_vote_post(notification) }}
    {% elseif notification.subject ==  'vote_comment' %}
        {{ render.render_vote_comment(notification) }}
    {% elseif notification.subject ==  'mention_user_in_topic' %}
        {{ render.render_at_user_in_topic(notification) }}
    {% elseif notification.subject ==  'mention_user_in_post' %}
        {{ render.render_at_user_in_post(notification) }}
    {% elseif notification.subject ==  'follow_category' %}
        {{ render.render_follow_category(notification) }}
    {% elseif notification.subject ==  'handle_withdraw' %}
        {{ render.render_handle_withdraw(notification) }}
    {% else %}
        {{ render.render_fallback(notification) }}
    {% endif %}
{% endmacro %}

{# 渲染好友关注 #}
{% macro render_follow_user(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%url%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username
                }
            %} notification.user_follow_you {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
    </div>
{% endmacro %}

{# 渲染回复话题 #}
{% macro render_reply_topic(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%topicUrl%':  path('topic_view', {id: notification.topic.id}),
                '%topicTitle%': notification.topic.title
                }
            %}
                notification.user_reply_your_topic
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染点赞话题 #}
{% macro render_vote_topic(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%topicUrl%':  path('topic_view', {id: notification.topic.id}),
                '%topicTitle%': notification.topic.title
                }
            %}
                notification.user_vote_your_topic
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|html_safe_chunk(0.5)|raw }}</div>
    </div>
{% endmacro %}

{# 渲染点赞话题回复 #}
{% macro render_vote_reply(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%topicUrl%':  path('topic_view', {id: notification.topic.id}),
                '%topicTitle%': notification.topic.title
                }
            %}
                notification.user_vote_your_reply
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染在话题@ #}
{% macro render_at_user_in_topic(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%topicUrl%':  path('topic_view', {id: notification.topic.id}),
                '%topicTitle%': notification.topic.title
                }
            %}
                notification.user_at_your_in_topic
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染在文章艾特 #}
{% macro render_at_user_in_post(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%postUrl%':  path('post_view', {id: notification.post.id}),
                '%postTitle%': notification.post.title
                }
            %}
                notification.user_at_your_in_post
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染评论文章 #}
{% macro render_comment_post(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%postUrl%':  path('post_view', {id: notification.post.id}),
                '%postTitle%': notification.post.title
                }
            %}
                notification.user_comment_your_post
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染点赞话题 #}
{% macro render_vote_post(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%postUrl%':  path('post_view', {id: notification.post.id}),
                '%postTitle%': notification.post.title
                }
            %}
                notification.user_vote_your_post
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|html_safe_chunk(0.5)|raw }}</div>
    </div>
{% endmacro %}

{# 渲染点赞话题回复 #}
{% macro render_vote_comment(notification) %}
    <div class="media-body">
        <div class="heading">
            {% trans with {
                '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                '%username%': notification.fromUser.username,
                '%postUrl%':  path('post_view', {id: notification.post.id}),
                '%postTitle%': notification.post.title
                }
            %}
                notification.user_vote_your_comment
            {% endtrans %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染订阅专栏通知 #}
{% macro render_follow_category(notification) %}
    <div class="media-body">
        <div class="heading">
            {% if notification.category.isBook  %}
                {% trans with {
                    '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                    '%username%': notification.fromUser.username,
                    '%bookUrl%':  path('book_view', {slug: notification.category.slug}),
                    '%bookTitle%': notification.category.name
                    }
                %}
                    notification.user_buy_your_book
                {% endtrans %}
            {% else %}
                {% trans with {
                    '%userUrl%': path('user_view', {username: notification.fromUser.username}),
                    '%username%': notification.fromUser.username,
                    '%categoryUrl%':  path('category_view', {slug: notification.category.slug}),
                    '%categoryTitle%': notification.category.name
                    }
                %}
                    notification.user_follow_your_category
                {% endtrans %}
            {% endif %}
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
    </div>
{% endmacro %}

{# 渲染处理提现通知 #}
{% macro render_handle_withdraw(notification) %}
    <div class="media-body">
        <div class="heading">
            <span>{{ 'notification.withdraw_notification'|trans }}</span>
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染默认 #}
{% macro render_fallback(notification) %}
    <div class="media-body">
        <div class="heading">
            <span>{{ notification.message|raw }}</span>
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
    </div>
{% endmacro %}